using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.Domain.Entity;
using NHibernate;
using NHibernate.Expression;

namespace Ghasam.Business.DAO.Impl
{
    public class ItemDao : DaoBase<Item>, IItemDao
    {

        public IList<Item> FindByNameLike(string name) {
            ICriteria crit = base.Session.CreateCriteria(typeof(Item));
            crit.Add(Expression.Like("Name", name, MatchMode.Start));
            return crit.List<Item>();
        }

        public Item FindByName(string name) {
            ICriteria crit = base.Session.CreateCriteria(typeof(Item));
            crit.Add(Expression.Like("Name", name, MatchMode.Exact));
            return crit.UniqueResult<Item>();
        }
    }
}
